package com.xukai.springboot.service.statistics;

import com.xukai.springboot.datalayer.statis.ChartDataSourceMapper;
import com.xukai.springboot.entity.statistics.t_statis_chart_datasource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChartDataSourceService {


    @Autowired
    ChartDataSourceMapper chartDataSourceMapper;

    /**
     * 查询数据源
     */
    public List<t_statis_chart_datasource> GetDataSourceList(int chartID) {
        return chartDataSourceMapper.GetDataSourceList(chartID);
    }

    /**
     * 保存数据源
     */
    public void SaveDataSource(int chartID, List<t_statis_chart_datasource> datas) {
        chartDataSourceMapper.ClearDataSource(chartID);
        for (t_statis_chart_datasource item : datas) {
            item.setChartID(chartID);
            chartDataSourceMapper.AddDataSource(item);
        }
    }

    /**
     * 清空数据源
     */
    public void ClearDataSource(int chartID) {
        chartDataSourceMapper.GetDataSourceList(chartID);
    }

}
